Skip to content

Rework <=, <, and >#871

Merged
jeaye merged 14 commits into
jank-lang:mainfrom
dgr:dgr-rework-comparisons
Apr 21, 2026
Merged

Rework <=, <, and >#871
jeaye merged 14 commits into
jank-lang:mainfrom
dgr:dgr-rework-comparisons

Conversation

@dgr
Copy link
Copy Markdown
Collaborator

@dgr dgr commented Apr 21, 2026

There were some tweaks that occurred for the >= PR during reviews. This PR updates <=, <, and > with similar changes. There is no associated issue for this work. Basically, across each of the three files:

  1. Uses are for testing arity 1.
  2. Cleans up spacing
  3. Adds some tests for equal numbers
  4. Removes negative tests that are testing outside the function contract.

Copy link
Copy Markdown
Member

@jeaye jeaye left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, pending copilot review.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the core comparator tests for <=, <, and > to align with the recent >= test refactors, primarily standardizing arity-1 checks, adding equality coverage, and removing out-of-contract negative cases.

Changes:

  • Refactors arity-1 tests to use are tables for <=, <, and >.
  • Adds additional equality test cases (e.g., equal rationals; repeated equal values in apply-forms).
  • Removes negative tests around non-numeric comparisons that are outside the functions’ intended contracts.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
test/clojure/core_test/lt_eq.cljc Refactors arity-1 <= tests and adjusts negative/equality coverage.
test/clojure/core_test/lt.cljc Refactors arity-1 < tests; adds equality and repeated-value coverage; trims negative cases.
test/clojure/core_test/gt.cljc Refactors arity-1 > tests; adds equality coverage; trims negative cases (but introduces a wrong-operator assertion).
Comments suppressed due to low confidence (1)

test/clojure/core_test/gt.cljc:94

  • The negative-test header comment mentions CLR implicit conversions for strings/chars to numbers, but the string/keyword comparison cases were removed in this PR. Consider updating the comment to match what the tests now cover (or reintroducing coverage if that behavior is still important to document).
      ;; `>` only compares numbers, except in ClojureScript (really
      ;; JavaScript under the hood) where comparisons are just a bit
      ;; of a mess. CLR also has some implicit conversions for strings
      ;; and characters to numbers.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread test/clojure/core_test/lt.cljc Outdated
(is (< :foo))
(is (< nil)))
(are [x] (= true (< x))
;; Doesn't matter what the argument is, `<` return `true` for
Comment thread test/clojure/core_test/gt.cljc Outdated
(is (> :foo))
(is (> nil)))
(are [x] (= true (> x))
;; Doesn't matter what the argument is, `>` return `true` for
Comment thread test/clojure/core_test/gt.cljc Outdated
(is (= true (apply > (reverse (range 10)))))
(is (= false (apply > -1 (reverse (range 10))))))
(is (= false (apply > -1 (reverse (range 10)))))
(is (= false (apply < (repeat 5 1)))))
Comment thread test/clojure/core_test/lt_eq.cljc Outdated
@jeaye
Copy link
Copy Markdown
Member

jeaye commented Apr 21, 2026

Another real bug caught by copilot. 💪

@dgr
Copy link
Copy Markdown
Collaborator Author

dgr commented Apr 21, 2026

Another real bug caught by copilot. 💪

Nice!

dgr and others added 2 commits April 21, 2026 14:49
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@jeaye jeaye merged commit 485de6b into jank-lang:main Apr 21, 2026
6 checks passed
@jeaye
Copy link
Copy Markdown
Member

jeaye commented Apr 21, 2026

Thanks, Dave!

@dgr dgr deleted the dgr-rework-comparisons branch April 21, 2026 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants